function drawNet(blocks){
	//清空net
	$$('.map-container .net').html('');
    //绘制网格
	var x,y,id;
	for(var i = 0;i < netNum.y;i++){
		  y = parseFloat(i*netrectH);
		  for(var j = 0;j < netNum.x;j++){
			  x = parseFloat(j*netrectW);
			  id = j.toString()+i.toString();
			  
			  var blockhtml = "<div class='path-block' "
			  +"blockid='"+id+"' data-axisX='"+j+"' data-axisY='"+i+"' "+"walkable='"+blocks[i][j]+"' "
			  +"style='top:"+y+"px;left:"+x+"px;width:"+netrectW+"px;height:"+netrectH+"px;'>"
			  +"</div>";
			  $$('.map-container .net').append(blockhtml);
		  }
	}
	//set walkable
	$$('.path-block[walkable="0"]').addClass('walkable');
	$$('.path-block[walkable="1"]').addClass('unwalkable');
}

function setCurrentPos(){
	//console.log(currentblock);
	//清除定位点
    $$('.current-icon').remove();
    $$('.path-block.current').removeClass('current');
    //添加新的定位点
    var cBlockid = currentblock[0].toString()+currentblock[1].toString();
    $$('[blockid="'+cBlockid+'"]').addClass('current');
    $$('.path-block.current').append(currenthtml);
}

function findPath(){
	grid = new PF.Grid(blocks);
    finder = new PF.AStarFinder({
    	allowDiagonal: true,
    	dontCrossCorners: true,
    	heuristic:PF.Heuristic.chebyshev
    });
    //console.log(startblock,endblock);
    pathroute = finder.findPath(startblock[0], startblock[1], endblock[0], endblock[1], grid);
    pathroute = PF.Util.smoothenPath(grid, pathroute);
    //console.log(pathroute);
}

function drawRoute(){
	//清空画布并重新绘制网格
	$$('#floor-canvas').attr('height',mapH);
	//获取起点
	var startposX = parseFloat(startblock[0])*netrectW+netrectW/parseFloat(2);
	var startposY = parseFloat(startblock[1])*netrectH+netrectH/parseFloat(2);
	ctx.beginPath();
	ctx.strokeStyle = '#0000FF';//轮廓颜色
	ctx.lineWidth = 2;//路径宽度
    ctx.moveTo(startposX,startposY);//设置起点
    //console.log("起点=>"+startposX+' '+startposY);
    //绘制路径
	var bindex;
	for(bindex in pathroute){
		var tragetX = parseFloat(pathroute[bindex][0])*netrectW+netrectW/parseFloat(2);
		var tragetY = parseFloat(pathroute[bindex][1])*netrectH+netrectH/parseFloat(2);
		ctx.lineTo(tragetX,tragetY);
   		//console.log(tragetX,tragetY);
	}
	ctx.stroke();
	//将地图居中
	$$('.map-container').transform('translate(0px,0px) scale(1)');
	//$$('.map-container').transition(500);
	$$('.map-container').data('axisX',0);
	$$('.map-container').data('axisY',0);
	$$('.map-container').data('scale',1);
}
function getMarkerPos(){
	var pathBleft = parseFloat($$('.path-block.active').css('left'));
	var pathBtop = parseFloat($$('.path-block.active').css('top'));
	var markerTop = pathBtop-markerSize;
	var markerLeft = pathBleft-markerSize/2;
	return {'x':markerLeft,'y':markerTop};
}